home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 November / PCWorld_2007-11_cd.bin / domácnost a kancelar / opencontacts / setup.exe / {app} / DataSet / Templates / VistaToOCXML.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2007-08-18  |  12.2 KB  |  317 lines

  1. ∩╗┐<?xml version="1.0" encoding="UTF-8"?>
  2. <!--For converting a Windows Vista Contact file into Open Contacts XML which may be imported into Open Contacts
  3. Based on this file, ImportVista.xsl is created for bulk importing contact files of Windows Vista.
  4. ImportVista.xsl is used by Open Contacts directly.
  5. -->
  6. <xsl:stylesheet version="1.0"
  7. xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:c="http://schemas.microsoft.com/Contact">
  8.   <xsl:output method="xml" omit-xml-declaration="yes" encoding="UTF-8" />
  9.  
  10.   <xsl:template match="c:contact">
  11.     <OpenContacts>
  12.       <Version_Info MajorVersion="1" MinorVersion="4"/>
  13.       <Locale Lang="en" CreateDate="20070810T052208Z"/>
  14.       <Contacts>
  15.         <Contact>
  16.  
  17.           <xsl:attribute name="Name">
  18.             <xsl:value-of select="c:NameCollection/c:Name/c:FormattedName"/>
  19.           </xsl:attribute>
  20.  
  21.           <xsl:attribute name="Title">
  22.             <xsl:value-of select="c:NameCollection/c:Name/c:Title"/>
  23.           </xsl:attribute>
  24.  
  25.           <xsl:attribute name="Surname">
  26.             <xsl:value-of select="c:NameCollection/c:Name/c:FamilyName"/>
  27.           </xsl:attribute>
  28.  
  29.           <xsl:attribute name="GivenName">
  30.             <xsl:value-of select="c:NameCollection/c:Name/c:GivenName"/>
  31.           </xsl:attribute>
  32.  
  33.           <xsl:attribute name="MidName">
  34.             <xsl:value-of select="c:NameCollection/c:Name/c:MiddleName"/>
  35.           </xsl:attribute>
  36.  
  37.           <xsl:attribute name="IsCompany">
  38.             <xsl:text>0</xsl:text>
  39.           </xsl:attribute>
  40.  
  41.           <Notes>
  42.             <xsl:value-of select="c:Notes"/>
  43.           </Notes>
  44.  
  45.           <Sections>
  46.             <Section Name="Personal">
  47.               <Fields>
  48.                 <xsl:for-each select="c:EmailAddressCollection/c:EmailAddress">
  49.                   <Field>
  50.                     <xsl:attribute name="Name">
  51.                       <xsl:if test="c:LabelCollection/c:Label='Preferred'">
  52.                         <xsl:text>Primary </xsl:text>
  53.                       </xsl:if>
  54.                       <xsl:text>Email</xsl:text>
  55.                     </xsl:attribute>
  56.  
  57.                     <xsl:attribute name="Value">
  58.                       <xsl:value-of select="c:Address"/>
  59.                     </xsl:attribute>
  60.                   </Field>
  61.                 </xsl:for-each>
  62.  
  63.                 <xsl:for-each select="c:PhoneNumberCollection/c:PhoneNumber">
  64.  
  65.                   <xsl:if test="c:LabelCollection/c:Label='Pager'">
  66.                     <Field>
  67.                       <xsl:attribute name="Name">Pager</xsl:attribute>
  68.                       <xsl:attribute name="Value">
  69.                         <xsl:value-of select="c:Number"/>
  70.                       </xsl:attribute>
  71.                     </Field>
  72.                   </xsl:if>
  73.  
  74.                   <xsl:if test="c:LabelCollection/c:Label='Cellular'">
  75.                     <Field>
  76.                       <xsl:attribute name="Name">Mobile</xsl:attribute>
  77.                       <xsl:attribute name="Value">
  78.                         <xsl:value-of select="c:Number"/>
  79.                       </xsl:attribute>
  80.                     </Field>
  81.                   </xsl:if>
  82.  
  83.                   <xsl:if test="c:LabelCollection/c:Label='Fax'">
  84.                     <xsl:if test="c:LabelCollection/c:Label='Personal'">
  85.                       <Field>
  86.                         <xsl:attribute name="Name">Fax</xsl:attribute>
  87.                         <xsl:attribute name="Value">
  88.                           <xsl:value-of select="c:Number"/>
  89.                         </xsl:attribute>
  90.                       </Field>
  91.                     </xsl:if>
  92.                   </xsl:if>
  93.  
  94.                   <xsl:if test="c:LabelCollection/c:Label='Voice'">
  95.                     <xsl:if test="c:LabelCollection/c:Label='Personal'">
  96.                       <Field>
  97.                         <xsl:attribute name="Name">Phone</xsl:attribute>
  98.                         <xsl:attribute name="Value">
  99.                           <xsl:value-of select="c:Number"/>
  100.                         </xsl:attribute>
  101.                       </Field>
  102.                     </xsl:if>
  103.                   </xsl:if>
  104.  
  105.                 </xsl:for-each>
  106.  
  107.                 <xsl:for-each select="c:UrlCollection/c:Url">
  108.                   <xsl:if test="c:LabelCollection/c:Label='Personal'">
  109.                     <Field>
  110.                       <xsl:attribute name="Name">Web</xsl:attribute>
  111.                       <xsl:attribute name="Value">
  112.                         <xsl:value-of select="c:Value"/>
  113.                       </xsl:attribute>
  114.                     </Field>
  115.                   </xsl:if>
  116.                 </xsl:for-each>
  117.  
  118.                 <xsl:for-each select="c:DateCollection/c:Date">
  119.                   <xsl:if test="c:LabelCollection/c:Label='wab:Birthday'">
  120.                     <Field>
  121.                       <xsl:attribute name="Name">Birthday</xsl:attribute>
  122.                       <xsl:attribute name="Value">
  123.                         <xsl:value-of select="substring(c:Value, 1, 10)"/>
  124.                       </xsl:attribute>
  125.                     </Field>
  126.                   </xsl:if>
  127.  
  128.                   <xsl:if test="c:LabelCollection/c:Label='wab:Anniversary'">
  129.                     <Field>
  130.                       <xsl:attribute name="Name">Anniversary</xsl:attribute>
  131.                       <xsl:attribute name="Value">
  132.                         <xsl:value-of select="substring(c:Value, 1, 10)"/>
  133.                       </xsl:attribute>
  134.                     </Field>
  135.                   </xsl:if>
  136.                 </xsl:for-each>
  137.  
  138.                 <xsl:for-each select="c:PersonCollection/c:Person">
  139.                   <xsl:if test="c:LabelCollection/c:Label='wab:Spouse'">
  140.                     <Field>
  141.                       <xsl:attribute name="Name">Spouse</xsl:attribute>
  142.                       <xsl:attribute name="Value">
  143.                         <xsl:value-of select="c:FormattedName"/>
  144.                       </xsl:attribute>
  145.                     </Field>
  146.                   </xsl:if>
  147.  
  148.                 </xsl:for-each>
  149.  
  150.                 <xsl:for-each select="c:PhysicalAddressCollection/c:PhysicalAddress">
  151.                   <xsl:if test="c:LabelCollection/c:Label='Personal'">
  152.  
  153.                     <Field>
  154.                       <xsl:attribute name="Name">Street</xsl:attribute>
  155.                       <xsl:attribute name="Value">
  156.                         <xsl:value-of select="c:Street"/>
  157.                       </xsl:attribute>
  158.                     </Field>
  159.  
  160.                     <Field>
  161.                       <xsl:attribute name="Name">City</xsl:attribute>
  162.                       <xsl:attribute name="Value">
  163.                         <xsl:value-of select="c:Locality"/>
  164.                       </xsl:attribute>
  165.                     </Field>
  166.  
  167.                     <Field>
  168.                       <xsl:attribute name="Name">State</xsl:attribute>
  169.                       <xsl:attribute name="Value">
  170.                         <xsl:value-of select="c:Region"/>
  171.                       </xsl:attribute>
  172.                     </Field>
  173.  
  174.                     <Field>
  175.                       <xsl:attribute name="Name">Postcode</xsl:attribute>
  176.                       <xsl:attribute name="Value">
  177.                         <xsl:value-of select="c:PostalCode"/>
  178.                       </xsl:attribute>
  179.                     </Field>
  180.  
  181.                     <Field>
  182.                       <xsl:attribute name="Name">Country</xsl:attribute>
  183.                       <xsl:attribute name="Value">
  184.                         <xsl:value-of select="c:Country"/>
  185.                       </xsl:attribute>
  186.                     </Field>
  187.  
  188.                   </xsl:if>
  189.                 </xsl:for-each>
  190.  
  191.               </Fields>
  192.             </Section>
  193.  
  194.             <Section Name="Work">
  195.               <Fields>
  196.  
  197.                 <xsl:for-each select="c:PositionCollection/c:Position">
  198.                   <Field>
  199.                     <xsl:attribute name="Name">Office</xsl:attribute>
  200.                     <xsl:attribute name="Value">
  201.                       <xsl:value-of select="c:Office"/>
  202.                     </xsl:attribute>
  203.                   </Field>
  204.  
  205.                   <Field>
  206.                     <xsl:attribute name="Name">Deaprtment</xsl:attribute>
  207.                     <xsl:attribute name="Value">
  208.                       <xsl:value-of select="c:Department"/>
  209.                     </xsl:attribute>
  210.                   </Field>
  211.  
  212.                   <Field>
  213.                     <xsl:attribute name="Name">Title</xsl:attribute>
  214.                     <xsl:attribute name="Value">
  215.                       <xsl:value-of select="c:JobTitle"/>
  216.                     </xsl:attribute>
  217.                   </Field>
  218.  
  219.                   <Field>
  220.                     <xsl:attribute name="Name">Company</xsl:attribute>
  221.                     <xsl:attribute name="Value">
  222.                       <xsl:value-of select="c:Company"/>
  223.                     </xsl:attribute>
  224.                   </Field>
  225.  
  226.                 </xsl:for-each>
  227.  
  228.                 <xsl:for-each select="c:PhoneNumberCollection/c:PhoneNumber">
  229.  
  230.                   <xsl:if test="c:LabelCollection/c:Label='Fax'">
  231.                     <xsl:if test="c:LabelCollection/c:Label='Business'">
  232.                       <Field>
  233.                         <xsl:attribute name="Name">Fax</xsl:attribute>
  234.                         <xsl:attribute name="Value">
  235.                           <xsl:value-of select="c:Number"/>
  236.                         </xsl:attribute>
  237.                       </Field>
  238.                     </xsl:if>
  239.                   </xsl:if>
  240.  
  241.                   <xsl:if test="c:LabelCollection/c:Label='Voice'">
  242.                     <xsl:if test="c:LabelCollection/c:Label='Business'">
  243.                       <Field>
  244.                         <xsl:attribute name="Name">Phone</xsl:attribute>
  245.                         <xsl:attribute name="Value">
  246.                           <xsl:value-of select="c:Number"/>
  247.                         </xsl:attribute>
  248.                       </Field>
  249.                     </xsl:if>
  250.                   </xsl:if>
  251.  
  252.                 </xsl:for-each>
  253.  
  254.                 <xsl:for-each select="c:PhysicalAddressCollection/c:PhysicalAddress">
  255.                   <xsl:if test="c:LabelCollection/c:Label='Business'">
  256.  
  257.                     <Field>
  258.                       <xsl:attribute name="Name">Street</xsl:attribute>
  259.                       <xsl:attribute name="Value">
  260.                         <xsl:value-of select="c:Street"/>
  261.                       </xsl:attribute>
  262.                     </Field>
  263.  
  264.                     <Field>
  265.                       <xsl:attribute name="Name">City</xsl:attribute>
  266.                       <xsl:attribute name="Value">
  267.                         <xsl:value-of select="c:Locality"/>
  268.                       </xsl:attribute>
  269.                     </Field>
  270.  
  271.                     <Field>
  272.                       <xsl:attribute name="Name">State</xsl:attribute>
  273.                       <xsl:attribute name="Value">
  274.                         <xsl:value-of select="c:Region"/>
  275.                       </xsl:attribute>
  276.                     </Field>
  277.  
  278.                     <Field>
  279.                       <xsl:attribute name="Name">Postcode</xsl:attribute>
  280.                       <xsl:attribute name="Value">
  281.                         <xsl:value-of select="c:PostalCode"/>
  282.                       </xsl:attribute>
  283.                     </Field>
  284.  
  285.                     <Field>
  286.                       <xsl:attribute name="Name">Country</xsl:attribute>
  287.                       <xsl:attribute name="Value">
  288.                         <xsl:value-of select="c:Country"/>
  289.                       </xsl:attribute>
  290.                     </Field>
  291.  
  292.                   </xsl:if>
  293.                 </xsl:for-each>
  294.  
  295.                 <xsl:for-each select="c:UrlCollection/c:Url">
  296.                   <xsl:if test="c:LabelCollection/c:Label='Business'">
  297.  
  298.                     <Field>
  299.                       <xsl:attribute name="Name">Web</xsl:attribute>
  300.                       <xsl:attribute name="Value">
  301.                         <xsl:value-of select="c:Value"/>
  302.                       </xsl:attribute>
  303.                     </Field>
  304.  
  305.                   </xsl:if>
  306.                 </xsl:for-each>
  307.  
  308.               </Fields>
  309.             </Section>
  310.  
  311.           </Sections>
  312.         </Contact>
  313.       </Contacts>
  314.     </OpenContacts>
  315.   </xsl:template>
  316.  
  317. </xsl:stylesheet>